@extends('layouts.art')
	
@section('content')

<link rel="stylesheet" href="/css/bootstrap-markdown.min.css">
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/js/bootstrap-markdown.js"></script>
 <script src="/js/markdown.js"></script>
 <script src="/js/to-markdown.js"></script>


	<form class="form-horizontal" method="post" action="{{route('blog.store')}}">
		   {{ csrf_field() }}
  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">标题</label>
    <div class="col-sm-8">
      <input type="title" class="form-control" id="title" name="title">
    </div>
  </div>


  <div class="form-group">
    <label for="inputEmail3" class="col-sm-2 control-label">内容</label>
    <div class="col-sm-8">
       <textarea class="form-control" rows="5" id="content" name="content"  data-provide="markdown" ></textarea>
    </div>
  </div>
   
  
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-10">

      <button type="submit" class="btn btn-default">创建</button>
    </div>
  </div>
</form>
<script type="text/javascript">
$.ajaxSetup({
    headers: { 'X-CSRF-TOKEN' : '{{ csrf_token() }}' }
});

$('#content').markdown({
	savable:true,
	onSave: function(e) {
    //alert("Saving '"+e.parseContent()+"'...");
     $.ajax({
        url: "{{route('blog.store')}}",
        type: "post",
        data: {
            content:e.parseContent(),
            title:$('#title').val()
        },
        success: function(res){
            
        },
        error: function(err){
            console.log(err.responseText);
        }
    });
  }
});
</script>
@endsection

